<!--
 * @author luguoxiang
 * @date 2022/9/17
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
-->
<template>
  <table-container>
    <lg-table :schema="schema" v-bind="tableProps">
      <!-- 工具栏 -->
      <template #toolbar-left>
        <lg-button-list :limit="$ToolBtnLimit">
          <t-button @click="offline()">强制下线</t-button>
          <template #trigger><btn-tool-more /></template>
        </lg-button-list>
      </template>
      <!-- 操作栏 -->
      <template #actionbar="{ row }">
        <lg-button-list :limit="$RowBtnLimit">
          <a @click="offline(row.id)">强制下线</a>
        </lg-button-list>
      </template>
      <!-- 插槽 -->
    </lg-table>
  </table-container>
</template>

<script setup lang="ts">
import { TableContainer } from '@/components';
import { LgButtonList, LgTable, useTable } from '@/soar';
import schema from './schema';
import api from './api';

// 使用表格
const { handleBatch, tableProps } = useTable<any>({
  api,
  props: {
    orderBys: ['id'],
    actionbar: {
      width: 100,
    },
  },
});

function offline(id?) {
  handleBatch((ids) => `确定强制${ids.length}个用户下线吗？`, api.offline, id);
}
</script>
